home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu620.dms / pu620.adf / Utilities / CACHEX.LHA / CacheX.Docs < prev    next >
Text File  |  1993-05-01  |  10KB  |  246 lines

  1.  
  2.         CacheX V1.0
  3.         by Steve Tibbett
  4.  
  5. INTRODUCTION
  6.  
  7. CacheX is a simple hard disk cache.  Simple because it doesn't buffer
  8. writes, nor get really fancy about caching.  But useful because it
  9. will cache anything, even things that the FileSystem buffers will not
  10. cache.  It has a friendly user interface, and is a commodity.  You can
  11. see the cache hit stats, free the buffers at any time, suspend the
  12. cache, and even tell it to hold onto the buffers it's got, to keep
  13. only specific items in the cache.  It caches an entire physical
  14. device, not just individual partitions, though it is limited to only
  15. one physical device.  CacheX requires Kickstart 3.0 or later and a
  16. 68020 or better processor.
  17.  
  18. I think it's important to mention that CacheX isn't just a cheap ripoff
  19. of something like HyperCache (which, I believe, is commercial) or any
  20. other cache program.  I wrote the first version of CacheX approximately
  21. two years ago, and intended to include it with my bulletin board.  I
  22. only recently decided to release it as shareware.
  23.  
  24. WARNING
  25.  
  26. CacheX's job is caching hard disk reads.  Bugs in CacheX, while none
  27. are known, could cause bad data to be read from your hard disk. 
  28. Before trying CacheX, it would be wise to make a backup, especially
  29. on systems that CacheX has not been tested with.  CacheX is known to
  30. work with the A3000 "scsi.device", but that is the only device I have
  31. tested it with.
  32.  
  33.  
  34. HOW IT WORKS: The Simple Explanation
  35.  
  36. You tell CacheX the name of a partition that is on the drive you want
  37. to cache, and CacheX figures out the device and unit that that
  38. partition resides on.  CacheX then begins caching any reads to that
  39. physical unit - so every partition on that device gets cached.
  40.  
  41.  
  42. HOW IT WORKS: Technically
  43.  
  44. When you tell CacheX the name of a partition to cache, it finds that
  45. partition in the device list, determines what Exec device and unit it
  46. pertains to, and opens that device and unit.  It looks at the io_Unit
  47. value that the device provides at OpenDevice() time, and remembers
  48. it.  Only IORequests to this device that have the same io_Unit value
  49. will be cached.  CacheX then SetFunction's the BeginIO() vector of
  50. the device, and checks every IORequest to see if it's for the unit
  51. we're caching, and if it is, checks to see if it's a CMD_READ.  If it
  52. is, it tries to fill the request from the buffers and if it cannot,
  53. it goes to the disk for the read.  When the read is done, CacheX then
  54. goes and fills it's own buffers from the data read from the disk. 
  55. Upon a CMD_WRITE, it refreshes any of it's own buffers that the data
  56. being written contains.
  57.  
  58. There are a few potential problems here.  One of them is that the
  59. device must use a unique io_Data value for each unit number, or
  60. else CacheX can't tell Unit 0 from Unit 1, for example, and might
  61. return the wrong data.  Another potential problem is that
  62. SendIO() effectively turns into DoIO(), since to cache the read,
  63. CacheX has to complete the read before returning from BeginIO().
  64.  
  65. CacheX is a low-memory-handler, so if a memory panic is about to fail
  66. a memory request, CacheX will step in and dump it's buffers which may
  67. allow the memory request to succeed.
  68.  
  69. CacheX uses the 3.0 memory pool system to allocate its buffers, and
  70. the buffers are allocated on demand (not all at once) but since they
  71. come from the end of memory, and are in pools of 32 buffers, memory
  72. fragmentation should not be a problem.
  73.  
  74. The CLIP option is normally set to 32K.  When the number of buffers
  75. in a read request is larger than this number of buffers, the read
  76. will not be cached.  This is to prevent very large reads from
  77. flushing all the buffers, and to speed things up when reading large
  78. files.  (Copying the data from the Read buffer into the Cache buffers
  79. takes an amount of time, and can actually slow down your hard disk
  80. the first time you read something).  If you want to cache every read,
  81. then set this value to a number larger than your number of buffers.
  82.  
  83.  
  84. FILESYSTEM BUFFERS VS CACHEX BUFFERS
  85.  
  86. If you are going to use CacheX, you should only use a few FileSystem
  87. buffers (ie, ADDBUFFERS, or changing the Buffers value in HDToolBox).
  88. 30 is a good number.  Since CacheX is a device cache, not a
  89. filesystem cache, it should happily cache blocks that foreign
  90. filesystems are using, such as the various MSDOS file systems out
  91. there.
  92.  
  93. The main reason CacheX was written, is because FFS refuses to cache
  94. reads of data bigger than 512 bytes.  What this means is that if you
  95. do something like "COPY C:LIST RAM:", it will go to the disk to get
  96. C:LIST every time, no matter how many buffers you have.  If you have
  97. a noisy hard drive, and if you are running a BBS, or any other
  98. program that accesses a lot of small data files often, this program
  99. should quieten things down.
  100.  
  101.  
  102. THE CACHEX WINDOW
  103.  
  104. When CacheX is started without the HIDE keyword, it will open a small
  105. window showing you the status of the cache, and give you some buttons
  106. you can push.  These are:
  107.  
  108. CACHE ACTIVE?        This checkbox is normally on.  When it is
  109.             off, CacheX will do nothing.
  110.  
  111. HOLD BUFFERS?        This checkbox is normally off.  When it is
  112.             on, CacheX will not allocate any new buffers,
  113.             keeping any data in the buffers from being
  114.             flushed.  Writes will still update the buffers
  115.             that are already in memory.  This option is
  116.             used for loading a set of data into the buffers
  117.             and then keeping it there.
  118.  
  119. BUFFERS:        This is the number of buffers.  Changing the
  120.             number of buffers will dump all data currently
  121.             in the buffers.  You have to hit return in this
  122.             gadget to actually change the number of buffers.
  123.  
  124. RESET STATS        This will clear the statistics showing the 
  125.             number of reads, writes, hits, and the hit
  126.             percentage.
  127.  
  128. HIDE            This will close the CacheX window.  See below for
  129.             more details.
  130.  
  131. QUIT            Terminate CacheX.
  132.  
  133. HOTKEY:            This is the commodities hotkey that you would
  134.             use to summon CacheX when it's window is
  135.             hidden.
  136.  
  137. When you HIDE the CacheX window, it will try and open the commodities
  138. library, and if it can, it will close it's window, and set itself up
  139. as a commodity.  Caching will continue normally.  When you hit the
  140. hotkey, or use Exchange to tell CacheX to open, CacheX will reopen
  141. it's window and remove itself as a commodity.
  142.  
  143.  
  144. OPTIONS
  145.  
  146. CacheX has a number of options, one of which is required (the name of
  147. the device to cache).  The options are indicated by the template
  148. "DEVICE/A,BUFFERS/N,HOTKEY/K,HIDE/S,CLIP/N", which are:
  149.  
  150. DEVICE/A    The name of the device to cache.  This should be the
  151.         name of any partition on the device you want to cache.
  152.  
  153. BUFFERS/N    A number, which is the number of buffers you want.
  154.         Each buffer is the size of the block on the device
  155.         you're using, normally 512 bytes, but on CDTV (for
  156.         example) this would be 2048 bytes.  (NOTE that this
  157.         program requires 2.04 so it won't work on CDTV).
  158.  
  159. HOTKEY/K    The commodities hotkey specifier, as described in the
  160.         2.0 manual, that will bring up CacheX when it is
  161.         hidden.  This string will normally contain a space,
  162.         so must be specified as HOTKEY="the string".
  163.  
  164. HIDE/S        This switch tells CacheX to come up hidden.  This is
  165.         useful for having it automatically start up, as in
  166.         your WBStartup drawer.
  167.  
  168. CLIP/N        This is the CLIP value as described in the technical
  169.         description above.  It's default value is 64 buffers, 
  170.         and you can normally leave it set to this.
  171.  
  172. FAST/S        Restrict CacheX to only using FAST memory for it's 
  173.         cache.  If you use a large number of buffers, you can
  174.         rely on the low memory handler to dump the buffers when
  175.         you run out of memory, restrict it to FAST ram, and 
  176.         all your unused fast ram will turn into a disk cache.
  177.         However, programs that ask for memory in this case may
  178.         have their requests for any memory return chip ram since
  179.         CacheX's low memory handler doesn't get told about this
  180.         situation.
  181.  
  182.  
  183. These options can be specified on the command line from CLI, or can
  184. be set as ToolTypes when CacheX is being started from Workbench.
  185.  
  186.  
  187. INSTALLATION:  Workbench
  188.  
  189. To run CacheX from Workbench, you can simply double-click on it's
  190. icon.  However, you must tell CacheX what device to cache.  You do
  191. this by getting Information... on the CacheX icon, and changing the
  192. DEVICE= tooltype to the device name you want to cache, as in
  193. "DEVICE=Work:" (without the quotes).  You can set any of the other
  194. options in the same manner.  Once you have edited the tooltypes,
  195. double-click on the icon and CacheX should open it's window.
  196.  
  197. To have CacheX automatically started when you reset your computer,
  198. you need to have it set up so the DEVICE= tooltype is present, and
  199. you also need a "DONOTWAIT" tooltype and the "HIDE" tooltype. When
  200. you have done this, drop CacheX's icon into your WBStartup drawer,
  201. and CacheX should automatically start up next time you reboot.  (You
  202. won't know it's there unless you go looking for it, since it will be
  203. hidden).
  204.  
  205.  
  206. INSTALLATION:  CLI
  207.  
  208. To run CacheX from CLI, you just have to give the device name.
  209. "CACHEX WORK:" will open the CacheX window and start caching the
  210. Work: device.  Any of the options listed above works as you would
  211. expect them to:  "CACHEX WORK: HIDE BUFFERS=1000 CLIP=500" would
  212. start CacheX with 1000 buffers, the clip value set to 500, and would
  213. not open the window.  Note that if you want CacheX to run in the
  214. background, you have to use RUN >NIL: <NIL: to get CacheX to not keep
  215. the shell window from closing.
  216.  
  217. THE AUTHOR
  218.  
  219. This program was originally written for a CDTV project, but ended up
  220. being useful enough to warrant general distribution.  Thanks must go
  221. to Jan van den Baard for his excellent GadToolsBox, which was used to
  222. create the user interface.
  223.  
  224. The author can be reached at:
  225.  
  226.          Portal:  SteveX
  227.         Bix:  s.tibbett
  228.          Usenet:  SteveX@cup.portal.com
  229.      Compuserve:  72627,1325
  230.         BBS:  613-731-3419
  231.            Home:  613-731-5316 (Evenings)
  232.  
  233.  
  234. In that order, if possible, for quick communications.  I often don't
  235. have time to answer paper mail in a timely manner, so if you have a
  236. question or bug report, please try and send me email, or just call me.
  237. My mail address is:
  238.  
  239.     Steve Tibbett
  240.     2710 Saratoga Pl. #1108
  241.     Gloucester, ON
  242.     K1T 1Z2 Canada
  243.  
  244. Program and documentation Copyright 1992 Steve Tibbett.  See the
  245. enclosed readme.txt file for more information about CacheX distribution.
  246.